#ifndef _FLASH_H_
#define _FLASH_H_

#include "main.h"

/* FLASH 扇区的起始地址,分2个bank,每个bank 1MB */
/* BANK1 */
#define BANK1_FLASH_SECTOR_0    ((uint32_t)0x08000000)      /* Bank1扇区0起始地址, 128 Kbytes */
#define BANK1_FLASH_SECTOR_1    ((uint32_t)0x08020000)      /* Bank1扇区1起始地址, 128 Kbytes */
#define BANK1_FLASH_SECTOR_2    ((uint32_t)0x08040000)      /* Bank1扇区2起始地址, 128 Kbytes */
#define BANK1_FLASH_SECTOR_3    ((uint32_t)0x08060000)      /* Bank1扇区3起始地址, 128 Kbytes */
#define BANK1_FLASH_SECTOR_4    ((uint32_t)0x08080000)      /* Bank1扇区4起始地址, 128 Kbytes */
#define BANK1_FLASH_SECTOR_5    ((uint32_t)0x080A0000)      /* Bank1扇区5起始地址, 128 Kbytes */
#define BANK1_FLASH_SECTOR_6    ((uint32_t)0x080C0000)      /* Bank1扇区6起始地址, 128 Kbytes */
#define BANK1_FLASH_SECTOR_7    ((uint32_t)0x080E0000)      /* Bank1扇区7起始地址, 128 Kbytes */
/* BNAK2 */
#define BANK2_FLASH_SECTOR_0    ((uint32_t)0x08100000)      /* Bank2扇区0起始地址, 128 Kbytes */
#define BANK2_FLASH_SECTOR_1    ((uint32_t)0x08120000)      /* Bank2扇区1起始地址, 128 Kbytes */
#define BANK2_FLASH_SECTOR_2    ((uint32_t)0x08140000)      /* Bank2扇区2起始地址, 128 Kbytes */
#define BANK2_FLASH_SECTOR_3    ((uint32_t)0x08160000)      /* Bank2扇区3起始地址, 128 Kbytes */
#define BANK2_FLASH_SECTOR_4    ((uint32_t)0x08180000)      /* Bank2扇区4起始地址, 128 Kbytes */
#define BANK2_FLASH_SECTOR_5    ((uint32_t)0x081A0000)      /* Bank2扇区5起始地址, 128 Kbytes */
#define BANK2_FLASH_SECTOR_6    ((uint32_t)0x081C0000)      /* Bank2扇区6起始地址, 128 Kbytes */
#define BANK2_FLASH_SECTOR_7    ((uint32_t)0x081E0000)      /* Bank2扇区7起始地址, 128 Kbytes */


#define flashsaveaddress  0x0801F000
#define flashsaveaddress_end  0x0801FFFF

extern uint64_t flash64bitbuff;

void FLASH_programword(uint32_t page_address,uint64_t DATA_64);
uint16_t MyFLASH_ReadHalfWord(uint32_t Address);
int FLASH_ErasePage(uint8_t Addr);

void FLASH_ReadPara(uint32_t addr, uint16_t*  u16Data, uint32_t len);
void FLASH_WritePara(uint32_t addr, uint16_t* u16Data, uint32_t len);

void dataread(void);//数据读取
void dataupdate(void);//数据更新

void Flash_EnableReadProtection(void);
void Flash_DisableReadProtection(void);

#endif


